﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace AcctrueWMS.Foundation.Data
{
    public class TextExpressionEvaler:IExpressionEvaler
    {
        public CommandExpressionTypeEnum ExpressionType
        {
            get { return CommandExpressionTypeEnum.Text; }
        }

        public IDataModelContext Context
        {
            get;
            set;
        }

        /// <summary>
        /// 使用vtl语法分析文本，并返回
        /// </summary>
        /// <param name="expr">vtl文本</param>
        /// <returns></returns>
        public object Eval(string expr)
        {
            TextWriter tw=new StringWriter();
            Context.Render.Render(expr,tw);
            tw.Flush(); tw.Close();
            return tw.ToString();
        }
    }
}
